{% comment %} 部分模板：资产调拨/转移表单（用于 AJAX 模态）{% endcomment %}
<div>
  {% if error %}
    <div class="alert alert-warning small">{{ error }}</div>
  {% endif %}
  <div class="mb-2 small text-muted">
    <strong>{{ asset.name }}</strong>
    {% if asset.asset_number %}<span class="ms-2">编号：{{ asset.asset_number }}</span>{% endif %}
  </div>
  <form method="post">
    {% csrf_token %}
    <div class="mb-3">
      <label for="ajax-transfer-department" class="form-label">转移到部门</label>
      <select class="form-select" id="ajax-transfer-department" name="department">
        <option value="" {% if not asset.department_id %}selected{% endif %}>清空部门</option>
        {% for department in departments %}
          <option value="{{ department.id }}" {% if asset.department_id == department.id %}selected{% endif %}>{{ department.name }}</option>
        {% endfor %}
      </select>
    </div>
    <div class="mb-3">
      <label for="ajax-transfer-user" class="form-label">转移给用户</label>
      <select class="form-select" id="ajax-transfer-user" name="user">
        <option value="" {% if not asset.user_id %}selected{% endif %}>清空使用人</option>
        {% for user in users %}
          <option value="{{ user.id }}" {% if asset.user_id == user.id %}selected{% endif %}>{{ user.get_full_name|default:user.username }}</option>
        {% endfor %}
      </select>
    </div>
    <div class="mb-3">
      <label for="ajax-transfer-description" class="form-label">备注</label>
      <textarea class="form-control" id="ajax-transfer-description" name="description" rows="3"></textarea>
    </div>
  </form>
</div>
